package org.black.phoneUtility.app.activity;

import java.util.List;

import org.black.phoneUtility.R;

import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.MenuItem;

public class PhoneUtilitySettingsActivity extends PreferenceActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			onBackPressed();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}

	@Override
	public void onBuildHeaders(List<Header> target) {
		loadHeadersFromResource(R.xml.phone_utility_preference_header, target);
	}

	@Override
	protected boolean isValidFragment(String fragmentName) {
		if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
			return super.isValidFragment(fragmentName);
		} else {
			if (org.black.phoneUtility.sms.reply.app.fragment.SmsReplyPreferenceFragment.class
					.getName().equals(fragmentName) == true
					|| org.black.phoneUtility.sms.schedule.app.fragment.SmsSchedulePreferenceFragment.class
							.getName().equals(fragmentName) == true) {
				return true;
			} else {
				return false;

			}
		}
	}

}
